<?php
/**
 * 
 * 删除用户
 * @author LeoNing
 *
 */
class DelUser extends Action {
	public function execute($params) {
		$me = check_login ( ADMIN_LOGIN_PAGE );
		if (! icando ( 'delete', 'user' )) {
			Response::errorPage ( "你无权删除用户.", $this->referer );
		}
		if (rqset ( 'uids' )) {
			$uid = safe_ids ( rqst ( 'uids' ), ',', true );
			$where ['uid IN'] = $uid;
		} else {
			$uid = irqst ( 'uid' );
			$where ['uid'] = $uid;
		}
		$where ['reserved'] = 0;
		$userModel = new CoreUserModel ();
		$userModel->begin ();
		$rst = apply_filter ( 'on_delete_user', true, $uid );
		if ($rst) {
			$rst = $userModel->delete ( $where );
			if ($rst !== false) {
				$userModel->commit ();
			} else {
				$userModel->rollback ();
			}
		}
		if ($rst === false) {
			Response::errorPage ( "删除用户失败。具体原因如下：<br/>" . $userModel->last_error_msg (), $this->referer );
		} else {
			Response::redirect ( $this->referer );
		}
	}
}